//----------------------------------------------------------------------------
//  ,-.
// /_\___ ,   CA Framework
// '  ___\    (C) Riccardo Capra - http://riccar.do
//  //   \\
//----------------------------------------------------------------------------
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------

#ifndef NJ_RAND_UINT_H
#	define NJ_RAND_UINT_H

#	include "NjExample01.h"

	/// \brief Generates random integer numbers in the range [\em uMin, \em uMax ) with flat distribution
	///
	/// Please note that \em uMax is not included in the range.
	template<typename tGenerator>
	class NjRandUint
	{
	public:
		/// \brief the random generator used by this class
		typedef tGenerator Generator;

		/// \brief Creates a random generator with range [0, Generator::RAND_MAX)
		NjRandUint();

		/// \brief Creates a random generator with range [\em uMin, \em uMax )
		NjRandUint(NjUint uMin, NjUint uMax);

		/// \brief Copies the random generator parameters from another NjRandUint
		NjRandUint(NjRandUint const & kCopy);

		/// \brief Copies the random generator parameters from another NjRandUint
		NjRandUint & operator=(NjRandUint const & kCopy);
		NJ_TRIVIAL_DESTRUCTOR(NjRandUint);

		/// \brief Returns the minimum number that can be generated
		NjUint GetMin() const;

		/// \brief Returns the maximum number plus one that can be generated
		NjUint GetMax() const;

		/// \brief Sets the generation range to [\em uMin, \em uMax )
		void SetMinMax(NjUint uMin, NjUint uMax);

		/// \brief Updates the minimum of the generation range to \em uMin
		void SetMin(NjUint uMin);

		/// \brief Updates the minimum of the generation range to \em uMax
		void SetMax(NjUint uMax);

		/// \brief Generates the next number
		NjUint operator() () const;

	private:
		/// \brief The minimum value in the range
		NjUint m_uMin;

		/// \brief The range modulo
		NjUint m_uModulo;
	};

#	include "NjRandUint_inline.h"

#endif // NJ_RAND_UINT_H
